package com.example.oasystem.service.impl;

import com.example.oasystem.dao.daymanage.AoaScheduleListDao;
import com.example.oasystem.entity.daymanage.AoaScheduleList;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DayManageServiceImpl {
    @Autowired
    AoaScheduleListDao scheduleListDao;
    public PageInfo<AoaScheduleList> getSche(int id, String text, int pageNum, int PageSize){
        PageHelper.startPage(pageNum, PageSize);

        List<AoaScheduleList> schedle = scheduleListDao.getSche(id, text);

        PageInfo<AoaScheduleList> deptPageInfo = new PageInfo<AoaScheduleList>(schedle);

        return deptPageInfo;
    }
    public int InsertShe(AoaScheduleList scheduleList){
        scheduleListDao.InsertShe(scheduleList);
        System.out.println(scheduleList);
        return Math.toIntExact(scheduleList.getRcId());

    }
    public void delUser(int rcid,List<Integer> userid){
        //先删除
        scheduleListDao.delUser(rcid);
        //再添加
        for (Integer integer : userid) {
            scheduleListDao.Insertuser2(rcid, integer);
        }
    }
    public void delShe(int rcid){


        scheduleListDao.delUser(rcid);
        scheduleListDao.delShe(rcid);
    }
}
